package com.example.demo.mapper;

import com.example.demo.bean.User;
import org.apache.ibatis.annotations.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

import java.util.List;
@Mapper
@Repository("UserMapper")
public interface UserMapper {
    //返回所有用户信息
    @Select("select * from user")
    public List<User> findAllUser();

    //判断用户名为name的用户是否已经存在表中

    @Select("select * from user " +
            "where userNum =#{userNum}")
    public User findUserByUserName(String userName);

    @Select("select * from user " +
            "where userNum =#{userNum} and userPwd =#{userPwd}")
    public User findUserByUser(String userNum, String userPwd);
    //向用户表中插入一条记录
    @Insert("insert into user(userNum , userPwd, member) " +
            "value(#{userNum}, #{userPwd}, #{member})")
    public boolean insertUser(String userNum, String userPwd, int member);

    //删除用户名为userName的用户
    @Delete("DELETE FROM user WHERe userNum = #{userNum}")
    public boolean deleteUser(String userNum);

    //通过用户名修改用户密码, 配合判断用户是否存在实现用户修改密码逻辑
    @Update("update User " +
            "set userPwd = #{userPwd} " +
            "where userNum = #{userNum}")
    public boolean updatePwd(String userNum, String userPwd);
}
